var _contextPath;

$(document).ready(function() {
	list();
	top.UppTabs.operator = top.getCurrentTagTitle();// 设置用户tab的标题值
});

/**
 * 查询用户列表
 */
function list() {
	_contextPath = $("#contextPath").val();
	$("#combocard_getlist").datagrid(
		{
			queryParams : {
				comboCardId:$("#comboCardId").val(),
				status:$("#status").val()
			},
			columns : [ [{
				field : 'comboCardSaleId',
				title : '',
				hidden : true,
				align : 'center'
			},{
				field : 'twoDimensionCode',
				title : '二维码ID',
				width : 100
			},{
				field : 'comboCardName',
				title : '套餐卡名称',
				width : 100,
				align : 'center'
			},{
				field : 'saleTime',
				title : '购买时间',
				width : 100,
				align : 'center',
				formatter : function(value, row, index) {
					return (new Date(Number(value))).dateConvert();
				}
			},{
				field : 'extractStatus',
				title : '提取状态',
				width : 100,
				align : 'center',
				formatter : function(value, row, index) {
					if (value == '0') {
						return '未提取';
					} else if (value == '1') {
						return '已提取';
					} else if (value == '2') {
						return '部分提取';
					} else {
						return '未提取';
					}
				}
			}, {
				field : 'expenseRecord',
				title : '提取详情',
				width : 200,
				align : 'center',
				formatter : function(value, row, index) {
					var str="";
					if(row.expenseRecord!=null && row.expenseRecord.length>0){
						for(var i=0;i<row.expenseRecord.length;i++){
							str = str + "<div>"+row.expenseRecord[i].merchantName +":"+(new Date(Number(row.expenseRecord[i].expenseTime))).dateConvert()+ "</div>";
						}
					}
					return str;
				}
			}] ],
			autoRowHeight : true,
			fitColumns : true,
			pagination : true,
			rownumbers : true,
			singleSelect : true
		});
}

function getContextPath() {
	if ("" == _contextPath) {
		_contextPath = $("#contextPath").val();
	}
	return _contextPath;
}

/**
 * 搜索
 * 
 * @return
 */
function searchKey() {
	$('#combocard_getlist').datagrid('load', {
		comboCardId:$("#comboCardId").val(),
		status:$("#status").val()
	});
}
